<nav xmlns:th="http://www.thymeleaf.org"
     th:fragment="pagination(totalCount, totalPage, curPage, curSize, link)"
     class="blog-pagination" aria-label="Page navigation example">
    <ul class="pagination" th:if="${totalCount >= curSize }">
        <!-- 上一页 -->
        <li th:class="${curPage == 1 ? 'page-item disabled' : 'page-item' }">
            <a class="page-link" th:href="@{${link}(page = ${curPage-1})}">上一页</a>
        </li>
        <!-- 总页数 <= 7 -->
        <th:blcok th:if="${totalPage <= 7}" th:remove="tag">
            <th:block th:each="i : ${#numbers.sequence(1, totalPage)}">
                <li th:class="${i == curPage ? 'page-item active' : 'page-item' }">
                    <a class="page-link" th:href="@{${link}(page = ${i})}">[[${i}]]</a>
                </li>
            </th:block>
        </th:blcok>
        <!-- 总页数 > 7 -->
        <th:block th:if="${totalPage > 7}" th:remove="tag">
            <!-- 当前页数 <= 3 -->
            <th:block th:if="${curPage <= 3}" th:remove="tag">
                <th:block th:each="i : ${#numbers.sequence(1, 7)}">
                    <li th:class="${i == curPage ? 'page-item active' : 'page-item' }">
                        <a class="page-link" th:href="@{${link}(page = ${i})}">[[${i}]]</a>
                    </li>
                </th:block>
            </th:block>
            <!-- 当前页数 > 3 -->
            <th:block th:if="${curPage > 3}" th:remove="tag">
                <th:block th:each="i : ${#numbers.sequence(curPage - 3, curPage - 1)}">
                    <li class="page-item">
                        <a class="page-link" th:href="@{${link}(page = ${i})}">[[${i}]]</a>
                    </li>
                </th:block>
                <li class="page-item active">
                    <a class="page-link" th:href="@{${link}(page = ${curPage})}">[[${curPage}]]</a>
                </li>
                <th:block th:each="i : ${#numbers.sequence(curPage + 1, curPage + 3)}">
                    <li class="page-item">
                        <a class="page-link" th:href="@{${link}(page = ${i})}">[[${i}]]</a>
                    </li>
                </th:block>
            </th:block>
        </th:block>
        <!-- 下一页 -->
        <li th:class="${curPage == totalPage ? 'page-item disabled' : 'page-item' }">
            <a class="page-link" th:href="@{${link}(page = ${curPage+1})}">下一页</a>
        </li>
    </ul>
</nav>